package routes

import (
	"net/http"
)

func SetupTestRoutes(router *http.ServeMux) {

	// 定义处理函数
	router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != http.MethodGet {
			http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
			return
		}
		_, err := w.Write([]byte("Hello World"))
		if err != nil {
			return
		}
		//fmt.Fprintf(w, "欢迎来到首页！")
	})

	router.HandleFunc("/test-api/test", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != http.MethodPost {
			http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
			return
		}
		w.Write([]byte("Hello World"))
	})

	router.HandleFunc("GET /test-api/test/{id}", func(writer http.ResponseWriter, request *http.Request) {
		writer.Write([]byte("ni hao" + request.PathValue("id")))
	})
}
